﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using AVCare.LMS.DataAccess;
using AVCare.LMS.Models;
using System.Web.Security;

namespace Web.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/

        public ActionResult Index()
        {
            IUserHelper helper = HelperProvider.GetUserHelper();
            User user = helper.GetUser("bjavc");
            List<Role> role = helper.GetUserRole(user.ID);
            string roles = string.Join<Role>(",", role);
            FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, "bjavc", DateTime.Now, DateTime.Now.AddHours(24), false, roles, "/");
            string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
            HttpCookie UserCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
            Response.Cookies.Add(UserCookie);

            return View();
        }
    }
}
